import java.util.ArrayList;

/**
 * Created by 蜡笔小新丶 on 2018/4/2.
 */
public class ExInform {
    private static User u;

    public static boolean RegCheck(User user) {
        boolean result = false;
        DAO dao = new DAO();
        if (dao.RestCheck(user.getNC()) &&
                dao.RestCheck(user.getUserNum())) {
            dao.addUser(user);
            result = true;
        }
        return result;
    }

    public static User getU() {
        return u;
    }

    public static void setU(User u) {
        ExInform.u = u;
    }

    public static boolean Login(String Unum, String Password) {
        Boolean result = false;
        DAO dao = new DAO();
        u = dao.LoginCheck(Unum, Password);
        if (u != null) {
            if (u.getUserNum().equals(Unum) && u.getUserPassW().equals(Password))
                result = true;
        }

        return result;
    }

    public static ArrayList<Jade> show() {
        DAO dao = new DAO();
        return dao.SelectShow();
    }

    public static boolean addJade(Jade j) {
        DAO dao = new DAO();
        if (dao.addCom(j))
            return true;
        else
            return false;
    }

    public static void dropJade(Jade j) {
        DAO dao = new DAO();
        dao.dropJade(j.getID());
    }

    public static void addMoney(User u, int m) {
        DAO dao = new DAO();
        dao.Cash(u.getUserNum(), m);
    }
    public  static void bought(buy m){
        DAO dao = new DAO();
        dao.bought(m);
    }

    public static boolean cha(String ID){
        DAO dao = new DAO();
        return dao.cha(ID);
    }
}
